﻿using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;
using GAS.Common.Managers;
using GAS.Common.DataSets;
using System.IO;
using System.Xml;

namespace GASWebServices
{
	/// <summary>
	/// Descripción breve de GASWebServiceUntyped
	/// </summary>
	[WebService(Namespace = "http://gas.mastermurcia.com/")]
	[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
	[ToolboxItem(false)]
	public class GASWebServiceUntyped : System.Web.Services.WebService
	{
		private GASManager manager;


		public GASWebServiceUntyped()
		{
			manager = new GASManager();
		}

		[WebMethod]
		public string[] GetAuditOptions(string auditCode)
		{
			return manager.GetAuditOptions(auditCode);
		}

		[WebMethod]
		public void SaveHostAudit(string auditDSXml, string auditCode)
		{
			AuditDataSet auditDS;

			auditDS = new AuditDataSet();
			try
			{
				auditDS.ReadXml(new XmlTextReader(new StringReader(auditDSXml)));
			}
			catch (Exception ex)
			{
				throw new Exception("The XML file have an incorrect format", ex);
			}
			manager.SaveHostAudit(auditDS, auditCode);
		}

		[WebMethod]
		public string GetLastAuditCode()
		{
			return manager.GetLastAuditCode();
		}
	}
}
